<?php
    ini_set('display_errors',1);
	ini_set('error_reporting',1);
	ini_set('display_startup_errors',1);
	error_reporting(E_ALL);
	// Include the PHP TwilioRest library
	require "Services/Twilio.php";
	
	if(isset($_REQUEST['From'])){
		var_dump($_REQUEST['From']);
		$file = "log.txt";
		$f = fopen($file,'wb');
		foreach($_REQUEST as $key => $val){
			$con = $key.":".$val;
			fwrite($f,$con,strlen($con)); 
		}
		//fwrite($f,$_REQUEST['From'],strlen($_REQUEST['From'])); 
		fclose($f); 
	}
	
	function sendSMS(){
		// Set our AccountSid and AuthToken
		$AccountSid = "AC015617a1e01b4cf09297fc31ca4846ae";
		$AuthToken = "6ba25acfcfea9ea96c5cb820411cf159";
		
		// Instantiate a new Twilio Rest Client
		$client = new Services_Twilio($AccountSid, $AuthToken);
		
		//echo"<pre>";var_dump($client->account->sms_messages);echo"</pre>";
		///* Your Twilio Number or Outgoing Caller ID */
		$from= '+14155992671';
		//
		//// make an associative array of server admins
		//$people = array(
		//	"+16464161640"=>"JA"
		//);
		
		$people = array(
			"+14155992671"=>"JA"
		);
		//
		//// Iterate over all our server admins
		foreach ($people as $to => $name) {
			// Send a new outgoinging SMS by POST'ing to the SMS resource */
			// YYY-YYY-YYYY must be a Twilio validated phone number
			//$body = "Bad news $name, the server is down and it needs your help";
			$body = "This is just an sms test please ignore it";
		
			$client->account->sms_messages->create($from, $to, $body);
			echo "Sent message to $name";
		}
	}
	
	
?>
